package com.yihong.portalserver.feignfallback;

import com.yihong.common.entity.User;
import com.yihong.common.util.AjaxJson;
import com.yihong.common.util.AjaxJsonFactory;
import com.yihong.portalserver.feign.UserFeign;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName UserFallBack
 * @Description
 * @Author 孟志浩
 * @Date 2019/3/18 16:20
 **/
@Component
public class UserFallBack implements UserFeign {

    /**
      * 
      * 调用失败返回信息
      * @return com.yihong.portalserver.feign.UserFeign
      * @author 孟志浩
      * @date 2019/3/18
      **/
    @Override
    public List<User> listUsers() {
        User u = new User();
        u.setLoginName("failed to call server [user server]");
        List l = new ArrayList();
        l.add(u);
        return l;
    }

    @Override
    public AjaxJson login(User user) {
        return AjaxJsonFactory.createAjaxJson(400, "登录失败，暂停服务");
    }

}
